package examples;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.util.*;

import com.hyperrealm.kiwi.ui.*;
import com.hyperrealm.kiwi.ui.model.*;
import com.hyperrealm.kiwi.util.*;
import com.hyperrealm.kiwi.ui.dialog.*;

public class TreeModelTest extends KFrame implements ActionListener
  {
  private ExternalKTreeModel model;
  private KTreeTable tree;
  private KButton b_refresh;
  FilesystemTableView ftv;
  
  public static void main(String args[])
    {
    TreeModelTest tmt = new TreeModelTest();
    tmt.setVisible(true);
    
/*    ResourceManager mgr = new ResourceManager(TreeModelTest.class);
      DocumentDataSource dds = new DocumentDataSource(mgr);
      
      DocumentBrowserFrame dbf = new DocumentBrowserFrame("Doc Test", "Hi there.", dds);
      
    dbf.setVisible(true);
*/
    }

  public TreeModelTest()
    {
    super("TreeModelTest");

    ftv = new FilesystemTableView();
    ftv.setRoot(new File("."));
    // ftv.getTable().setRootVisible(true);
    KPanel p = getMainContainer();

    p.setLayout(new BorderLayout(5, 5));

    p.add("Center", ftv);

    /*
      FilesystemTreeView ftrv = new FilesystemTreeView();
    ftrv.setRoot(new File("/export/home/markl/man"));

    p.add("Center", ftrv);
    */

    setSize(500, 500);

    b_refresh = new KButton("Refresh Children");
    b_refresh.addActionListener(this);

    p.add("South", b_refresh);
    }

  public void actionPerformed(ActionEvent evt)
    {
    Object o = evt.getSource();

    if(o == b_refresh)
      {
      File f = ftv.getSelectedFile();

      System.out.println(f);

      KTreeTable trtbl = ftv.getTable();
      
      }
    }
  
  }
